/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.common.i;

import java.net.URLDecoder;
import java.net.URLEncoder;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;

public class f {
    public static String a(String paramString1, String paramString2) {
        return a(c(paramString1, paramString2));
    }

    public static String b(String paramString1, String paramString2) {
        return d(b(paramString1), paramString2);
    }

    public static String c(String paramString1, String paramString2) {
        return a(e(paramString1, paramString2));
    }

    public static String d(String paramString1, String paramString2) {
        return a(c(paramString1), paramString2);
    }

    public static byte[] e(String paramString1, String paramString2) {
        byte[] arrayOfByte = null;
        if ((paramString1 != null) && (paramString1.length() > 0))
            try {
                Cipher localCipher = d(paramString2);
                arrayOfByte = localCipher.doFinal(paramString1.getBytes("UTF-8"));
            } catch (Exception localException) {
                c.b("EncryptUtil", new Object[] { localException.toString() });
            }
        return arrayOfByte;
    }

    public static String a(byte[] paramArrayOfByte) {
        String str = null;
        if (paramArrayOfByte != null)
            try {
                str = a.b(paramArrayOfByte, 2);
            } catch (Exception localException) {
                c.b("EncryptUtil", new Object[] { localException.toString() });
            }
        return str;
    }

    public static String a(String paramString) {
        String str = null;
        if ((paramString != null) && (paramString.length() > 0))
            try {
                str = URLEncoder.encode(paramString, "UTF-8");
            } catch (Exception localException) {
                c.b("EncryptUtil", new Object[] { localException.toString() });
            }
        return str;
    }

    public static String b(String paramString) {
        String str = null;
        if ((paramString != null) && (paramString.length() > 0))
            try {
                str = URLDecoder.decode(paramString, "UTF-8");
            } catch (Exception localException) {
                c.b("EncryptUtil", new Object[] { localException.toString() });
            }
        return str;
    }

    public static byte[] c(String paramString) {
        byte[] arrayOfByte = null;
        if ((paramString != null) && (paramString.length() > 0))
            try {
                arrayOfByte = a.a(paramString, 2);
            } catch (Exception localException) {
                c.b("EncryptUtil", new Object[] { localException.toString() });
            }
        return arrayOfByte;
    }

    public static String a(byte[] paramArrayOfByte, String paramString) {
        String str = null;
        if (paramArrayOfByte != null)
            try {
                Cipher localCipher = e(paramString);
                byte[] arrayOfByte = localCipher.doFinal(paramArrayOfByte);
                str = new String(arrayOfByte, "UTF-8");
            } catch (Exception localException) {
                c.b("EncryptUtil", new Object[] { localException.toString() });
            }
        return str;
    }

    public static Cipher d(String paramString) {
        DESKeySpec localDESKeySpec = new DESKeySpec(paramString.getBytes("UTF-8"));
        SecretKeyFactory localSecretKeyFactory = SecretKeyFactory.getInstance("DES");
        SecretKey localSecretKey = localSecretKeyFactory.generateSecret(localDESKeySpec);
        Cipher localCipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
        IvParameterSpec localIvParameterSpec = new IvParameterSpec(paramString.getBytes("UTF-8"));
        localCipher.init(1, localSecretKey, localIvParameterSpec);
        return localCipher;
    }

    public static Cipher e(String paramString) {
        DESKeySpec localDESKeySpec = new DESKeySpec(paramString.getBytes("UTF-8"));
        SecretKeyFactory localSecretKeyFactory = SecretKeyFactory.getInstance("DES");
        SecretKey localSecretKey = localSecretKeyFactory.generateSecret(localDESKeySpec);
        Cipher localCipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
        IvParameterSpec localIvParameterSpec = new IvParameterSpec(paramString.getBytes("UTF-8"));
        localCipher.init(2, localSecretKey, localIvParameterSpec);
        return localCipher;
    }
}